package com.loyal.loyalerp.humenresource.kaoqinMonth.service;

import java.util.List;

import com.github.pagehelper.PageInfo;
import com.loyal.loyalerp.humenresource.askleave.model.AskLeave;
import com.loyal.loyalerp.humenresource.kaoqinMonth.model.RsKaoqinmonth;
import com.loyal.loyalerp.model.GyPerson;
import com.loyal.loyalerp.model.vo.CompanyIdAndYears;

public interface KaoqinMonthService {

	//加载所有考勤月结数据并排序
	PageInfo<RsKaoqinmonth> listKaoqinMonth(Integer pageNum, Integer pageSize, String sidx,String sord);

	//加载数据
	int initData();
	
	/**
	 * 判断某月份是否已经被初始化
	 * 1.根据companyname得到companyId
	 * 2.根据companyId+year+month判断该记录是否已经在kaoqonMonth表中存在
	 */
	int selectCompanyIdByCompanyName(String companyname);
	int selectByCY(RsKaoqinmonth km);
	
	//初始化
	int start(RsKaoqinmonth km);
	
	//如果上一年没有全部月结，就不能初始化下一年
	boolean judge(int companyId,int year);
	
	//判断该月份的请假表是否被审核
	//根据year+month得到这个月的所有请假记录
	//根据personId查companyId
	//companyId+personId+KjYear+Period+Days插入到考勤表中
	public List<AskLeave> checkAsk(int year,int month);
	
	//companyId
	GyPerson getPerson(int personId);
	
	void updateByCPYPD(int companyId,AskLeave askLeave);
	
	//根据year+month+companyId查到该月的月结记录
	int updateCloseFlag(int companyId,int year,int month) throws Exception;
	
	//插入一条新的数据
	void insertPreviousYear(RsKaoqinmonth km);

	
	//查上个月有没有月结
	int selectCloseFlag(RsKaoqinmonth km);
	
	//根据companyID+year+month查询该记录存在不
	RsKaoqinmonth selectByCYM(RsKaoqinmonth km);
	

	//模糊查询
	public PageInfo<RsKaoqinmonth> findKm(Integer pageSize,Integer pageNum, String searchField, String searchString);
	

	int selectLastYearHasEnd(CompanyIdAndYears years);
}
